package com.zoweunion.mechanic.dao.order;

import com.zoweunion.mechanic.entity.AuxiliaryRepairMenBean;
import com.zoweunion.mechanic.entity.MainRepairMenBean;
import com.zoweunion.mechanic.entity.RepairBean;
import com.zoweunion.mechanic.util.entity.OrderBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Mapper
@Component
public interface KFOrderDao {
	/**
	 * 分页+条件查询
	 */
	List<Map<String,Object>>listByStatus(Map<String, Object> reqMap);

	/**
	 * 根据条件查询总个数
	 * @param reqMap
	 * @return
	 */
	int countBycondition(Map<String, Object> reqMap);


	/**
	 * 获取故障列表
	 * @param reqMap
	 * @return
	 */
	List<Map<String, Object>> getfaultList(Map<String, Object> reqMap);

	/**
	 * 创建主工单
	 * @param reqMap
	 */
	int createOrder(Map<String, Object> reqMap);


	/**
	 * 创建工单明细_故障关联
	 * @param map
	 * @return
	 */
	int createOrderFault(Map<String, Object> map);


	/**
	 * 创建工单明细
	 * @param reqMap
	 * @return
	 */
	int createOrderDetail(Map<String, Object> reqMap);


	/**
	 * 更新总工单信息
	 * @param reqMap
	 * @return
	 */
	int updateOrderInfo(Map<String, Object> reqMap);


	/**
	 * 根据总工单id删除状态比当前状态大的工单明细
	 * @param reqMap
	 */
	void updateOrderDetail(Map<String, Object> reqMap);

	/**
	 * 创建工单_修工关联biao
	 * @param repairmanMap
	 * @return
	 */
	int createRepairman(Map<String, Object> repairmanMap);

	/**
	 * 更新工单_修工关联表
	 * @param repairmanMap
	 */
	void updateRepairman(Map<String, Object> repairmanMap);


	/**
	 * 更新工单_修工关联表
	 * @param repairmanMap
	 */
	String getRepairMoneyTime(Map<String, Object> repairmanMap);


	/**
	 * 根据工单id查询总工单信息
	 * @param reqMap order_id
	 * @return
	 */
	Map<String, Object> getOrderInfoByOrderId(Map<String, Object> reqMap);

	/**
	 * 根据工单id关联查询故障列表
	 * @param orderMap
	 * @return
	 */
	List<Map<String, Object>> getOrderFaultByOrderId(Map<String, Object> orderMap);

	/**
	 * 根据工单id查询修工信息
	 * @param orderMap
	 * @return
	 */
	List<Map<String, Object>> getOrderRepairmanByOrderId(Map<String, Object> orderMap);

	/**
	 * 根据总工单中的保养时长m_id 获取保养配件清单
	 * @param orderMap m_id
	 * @return
	 */
	List<Map<String, Object>> getUpkeepInfoByMId(Map<String, Object> orderMap);

	/**
	 * 根据order_id p_type change_flag查询配件信息
	 * @param reqMap
	 * @return
	 */
	List<Map<String, Object>> getPartsByCondition(Map<String, Object> reqMap);

	/**
	 * 根据order_id change_flag=0  将 t_s_br_order_detail_parts  delete_flag设为1
	 * @param reqMap order_id
	 */
	int deleteOrderParts(Map<String, Object> reqMap);



	/**
	 * 根据order_id  change_flag=1或者2   将t_s_br_order_detail_parts delete_flag设为2
	 * @param reqMap order_id
	 */
	int updateOrderParts(Map<String, Object> reqMap);

	/**
	 * 创建工单_配件
	 * @param orderPartsMap
	 * @return
	 */
	int createOrderParts(Map<String, Object> orderPartsMap);


	/**
	 * 创建投诉处理记录
	 * @param complaintHandleMap
	 * @return
	 */
	int insertComplaintHandle(HashMap<String, Object> complaintHandleMap);


	/**
	 * 投诉列表条件分页查询
	 * @param reqMap 条件分页查询
	 */
	List<Map<String,Object>> listComplaintHandle(Map<String, Object> reqMap);

	/**
	 * 投诉工单查询总数
	 * @param reqMap
	 * @return
	 */
	int countComplaintHandle(Map<String, Object> reqMap);
	/**
	 * 获取投诉工单详情 关联到服务人员车辆信息
	 * @param reqMap
	 * @return
	 */
	Map<String, Object> getComplaintHandleInfo(Map<String, Object> reqMap);

	/**
	 * 更新Complaint_handle
	 * @param reqMap
	 * @return
	 */
	int updateComplaint_handle(Map<String, Object> reqMap);

	/**
	 * 记录授权日志
	 */
	int insertAuthLog(Map<String, Object> map);

	/**
	 * 客户提出优惠,打折更改相应配件价格
	 */
	int updatePartsPrice(@Param("p_id") String p_id, @Param("price") String price, @Param("discount_price") String discountPrice, @Param("order_id") String order_id);

	/**
	 * 客服获取可优惠工单
	 * @param reqMap
	 */
	List<Map<String, Object>> getDiscountOrderList(Map<String, Object> reqMap);

	/**
	 * 根据客服选择的可优惠的配件信息筛选出相应的工单,然后推送给高管
	 * @param order_id
	 */
	Map<String, Object> getDiscountOrderListByParts(@Param("p_id") String p_id, @Param("order_id") String order_id);

	int handleFlag(Map<String, Object> resultMap);

	List<Map<String, Object>> getOrderDetail(@Param("order_id") String order_id);

	List<Map<String, Object>> getOrderPartsDetail(@Param("order_id") String order_id);

	List<Map<String, Object>> getDiscountOrderInfo();

	List<Map<String, Object>> getGgDiscountOrderList(Map<String, Object> reqMap);

	List<Map<String, Object>> getCarInfo(Map<String, Object> orderMap);

	String getTZname(Map<String, Object> orderMap);

	String getRegionByProvince(@Param("province") String province);

	List<String> getDictionariesName(Map<String, Object> orderMap);

	List<Map<String, Object>> getDictionariesNameBy(Map<String, Object> orderMap);

	Map<String, Object> getTzInfoByOrderId(@Param("order_id") String order_id);

	List<Map<String, Object>> getXgInfoByOrderId(@Param("order_id") String order_id);

	List<Map<String, Object>> getOrderInfoAndContactByOrderId(@Param("order_id") String order_id);

	int getCountByDiscountOrder(Map<String, Object> reqMap);

	int getCountByRoleIdUserId(Map<String, Object> reqMap);

	int getCountByXgUserId(Map<String, Object> reqMap);

	String getOrderTupeByOrderId(@Param("order_id") String order_id);

	List<Map<String, Object>> findUserByRid(Map<String, Object> reqMap);

	List<String> findXgId(Map<String, Object> reqMap);

	Map<String, Object> getOrderInfo(@Param("order_id") String order_id);

	List<Map<String, Object>> getOrderDetailParts(@Param("order_id") String order_id);

	List<Map<String, Object>> getOrderDetalInfo(@Param("order_id") String order_id);

	List<Map<String, Object>> getordeList(Map<String, Object> orderMap);

	List<Map<String, Object>> listCarMaster(@Param("s_id") String s_id);

	List<Map<String, Object>> listWaitBackOrder(@Param("s_id") String s_id);

    List<OrderBean> getOrderList(Map<String, Object> params);

    RepairBean getRepair(Map<String, Object> params);

    MainRepairMenBean getMainRepairMen(Map<String, Object> params);

    AuxiliaryRepairMenBean getAuxiliaryRepairMen(Map<String, Object> params);

    List<Map<String, Object>> getRepairPay(Map<String, Object> params);
}
